CREATE TABLE joinway_gongshi(
	[id] [char](32) NULL,
	[userid] [int] NULL,
	[date] [char](10) NULL,
	[cid] [int] NULL,
	[ajid] [int] NULL,
	[gzdm] [int]NULL,
	[gznr] [varchar](4096) NULL,
	[gzsh] [decimal](15, 2) NULL,
	[shuxing] [int] NULL,
	[jbls] [varchar](512) NULL,
	[gzshqr] [decimal](15, 2) NULL,
	[shuxingqr] [int] NULL,
	[hbls] [varchar](512) NULL
)
GO

select * into anjian_shareinfo from CRM_ShareInfo where 1=2
GO

alter table docdetail add anjianid int
GO

create function clearhtml (@maco varchar(8000))
returns varchar(8000) 
as 
begin
    declare @randchar_one nvarchar(200)
    declare @randchar_two nvarchar(200)
       if(charindex('<<',@maco)>0)
              begin
                     set @randchar_one='D4678B36-B958-4274-B81E-BBA636CFB427';
                     set @randchar_two='49E374CC-9E1A-4850-897C-27074DE32E7F';
                     set @maco=replace(@maco,'<<',@randchar_one)
                     set @maco=replace(@maco,'>>',@randchar_two)
              end
    declare @i int
    while 1 = 1 
    begin
       set @i=len(@maco)
       set @maco=replace(@maco, substring(@maco,charindex('<',@maco),
       charindex('>',@maco)-charindex('<',@maco)+1),space(0))
       if @i=len( @maco ) 
       break 
    end
 
    set @maco=replace(@maco,' ','')
    set @maco=replace(@maco,'&nbsp;','')
    set @maco=ltrim(rtrim(@maco))
    set @maco=replace(@maco,char(9),'')
    set @maco=replace(@maco,char(10),'')
    set @maco=replace(@maco,char(13),'')
    if(charindex(@randchar_one,@maco)>0)
    begin
       set @maco=replace(@maco,'D4678B36-B958-4274-B81E-BBA636CFB427','<<')
       set @maco=replace(@maco,'49E374CC-9E1A-4850-897C-27074DE32E7F','>>')
    end
    return (@maco)
end
GO

select * into anjian_log from crm_log where 1=2
GO

alter table docdetail drop column anjianid
GO

alter table docdetail add stockid int
GO

alter table joinway_gongshi add status int
GO

alter table joinway_gongshi add createdate char(10)
GO


